@(adv: Advertisement, comments: List[Comment], commentForm: Form[Comment])

@import helper._
@import controllers.user.UserController


@main(adv.getName()) {

	<div class="panel panel-success" style=" width: 70%; align: center;">
		<div class="panel-heading">
			<h5 class="panel-title">@adv.getName()
				@if(session.get("currentUserEmail") != null && UserController.getCurrentUser().getPriv("worker")){
		 		<a class="pull-right" href="/advertisement/delete/@adv.getId()"><font color="red">x</font></a>
		 		}
		 	</h5>
		</div>

		<div class="panel-body">
			<img class="img-rounded img-responsive" src="@routes.Assets.at("images/advertisement/")@adv.getPhoto()"/>
			<hr />
			<p>Price: @adv.getPrice() HUF </p><br />
			<p>Description: @adv.getDescription()</p>
			<a href="javascript:history.go(-1)"><-back</a>
		</div>
		<div class="panel-footer">
			@form(controllers.advertisement.routes.AdvertisementController.addComment(adv.getId())){
				@helper.input(field = commentForm("text"), '_label -> "") { (id, name, value, args) =>
					   <div>
        			<textarea name="@name" id="@id" rows='5' placeholder="Type comment ..." style="width:100%;">@value</textarea>
				     </div>
				}
				
				<input class="btn btn-success btn-sm" type="submit" value="Comment" @if(session.get("currentUserEmail") == null){disabled="disabled"}>
			}	

				@if(comments != null){
					@for(comment <- comments){
						<div class="row">
							
							<h5 class="col-md-6">
								<strong>@comment.getUser().getEmail()</strong>
							</h5>
							<h5 class="col-md-6 text-right">
								<strong>@comment.getDate().toLocaleString()</strong>
							</h5>
						</div>
						<div>
							@comment.getText()
						</div>
						<hr />
						<br />
						
				}
				}else{
					<p> There are no comments yet!
				}
			</div>
	</div>
	
}